home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / akcl / akcl1615.lha / c / rel_coff.c < prev    next >
C/C++ Source or Header  |  1989-06-02  |  2KB  |  77 lines

  1.  
  2. /* Copyright William Schelter. All rights reserved.  This file does
  3. the low level relocation which tends to be very system dependent.
  4. It is included by the file sfasl.c
  5. */
  6.  
  7.  
  8. relocate()
  9. {
  10.   char *where;
  11.   describe_sym(relocation_info.r_symndx);
  12.   where = the_start + relocation_info.r_vaddr;
  13.   dprintf (where has %x , *where);
  14.   dprintf(   at %x -->, where );
  15.   
  16.   if (relocation_info.r_type == R_ABS)
  17.     { dprintf( r_abs ,0)  return; }
  18.   switch(relocation_info.r_type)
  19.     { int *q;
  20.     case R_DIR32:
  21.       dprintf(new val r_dir32 %x ,  *((int *)where) + 
  22.           symbol_table[relocation_info.r_symndx].n_value);
  23.       *(int *)where= *((int *)where) + 
  24.     symbol_table[relocation_info.r_symndx].n_value;
  25.       break;
  26.     case R_PCRLONG:
  27.  
  28.       dprintf( r_pcrlong new value = %x ,
  29.           *((int *)where)  - (int)start_address
  30.           + symbol_table[relocation_info.r_symndx].n_value );
  31.       *(int *)where=  *((int *)where)  - (int)start_address
  32.     + symbol_table[relocation_info.r_symndx].n_value;
  33.       break;
  34.     default:
  35.       fprintf(stdout, "%d: unsupported relocation type.",
  36.           relocation_info.r_type);
  37.       FEerror("The relocation type was unknown",0,0);
  38.     }
  39.  
  40. }
  41.  
  42.  
  43.  
  44.  
  45. #ifdef DEBUG
  46.  
  47. #define describe_sym describe_sym1
  48. describe_sym1(n)
  49. int n;
  50. {char *str;
  51.  char tem[9];
  52.  struct syment *sym;
  53.  sym= &symbol_table[n];
  54.  str= sym->n_zeroes == 0 ?
  55.    &my_string_table[sym->n_offset] :
  56.  (sym->n_name[SYMNMLEN -1] ?
  57.   /* MAKE IT NULL TERMINATED */
  58.   (strncpy(tem,sym->n_name,
  59.        SYMNMLEN),tem):
  60.   sym->n_name );
  61.  printf ("sym-index = %d table entry at %x",n,&symbol_table[n]);
  62.  printf("symbol is (%s):\nsymbol_table[n]._n._n_name %s\nsymbol_table[n]._n._n_n._n_zeroes %d\nsymbol_table[n]._n._n_n._n_offset %d\nsymbol_table[n]._n._n_nptr[0] %d\nsymbol_table[n]._n._n_nptr[n] %d\nsymbol_table[n].n_value %d\nsymbol_table[n].n_scnum %d
  63. \nsymbol_table[n].n_type %d\nsymbol_table[n].n_sclass %d\nsymbol_table[n].n_numaux %d", str,
  64.     symbol_table[n]._n._n_name,
  65.     symbol_table[n]._n._n_n._n_zeroes ,
  66.     symbol_table[n]._n._n_n._n_offset ,
  67.     symbol_table[n]._n._n_nptr[0] ,
  68.     symbol_table[n]._n._n_nptr[1] ,
  69.     symbol_table[n].n_value ,
  70.     symbol_table[n].n_scnum ,
  71.     symbol_table[n].n_type ,
  72.     symbol_table[n].n_sclass ,
  73.     symbol_table[n].n_numaux );
  74. }
  75.  
  76. #endif 
  77.